package tung.niit.ict;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.Toast;

public class MainUI extends Activity {

	private EditText edTenDangNhapLogin;
	private EditText edMatKhauLogin;
	
	private TabHost tab;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_ui);
		
		edTenDangNhapLogin = (EditText)findViewById(R.id.editUserName);
		edMatKhauLogin = (EditText)findViewById(R.id.editPassword);
		
		tab = (TabHost)findViewById(android.R.id.tabhost);
		tab.setup();
		TabHost.TabSpec spec;
		
		spec = tab.newTabSpec("t1");
		spec.setContent(R.id.tab1);
		spec.setIndicator("Login");
		tab.addTab(spec);
		
		spec = tab.newTabSpec("t2");
		spec.setContent(R.id.tab2);
		spec.setIndicator("Register");
		tab.addTab(spec);
		
		tab.setCurrentTab(0);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main_ui, menu);
		return true;
	}
	
	public void onLogin(View view) {
		String userName = edTenDangNhapLogin.getText().toString().trim();
		String password = edMatKhauLogin.getText().toString().trim();
		
		if (userName.equalsIgnoreCase("") || password.equalsIgnoreCase("")) {
			Toast.makeText(this, "Ban chua dien du thong tin", Toast.LENGTH_SHORT).show();
			return;
		}
		
		if (userName.equals("tungnm") && password.equals("1234")) {
//			Toast.makeText(this, "Ban nhap chinh xac", Toast.LENGTH_SHORT).show();
			Intent intent = new Intent(MainUI.this, Information.class);
			startActivity(intent);
			finish();
			return;
		}
		else {
			Toast.makeText(this, "Ten hoac mat khau sai hoac ban chua dang ky", Toast.LENGTH_SHORT).show();
			return;
		}
	}

}
